<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="cmd.css" rel="stylesheet" type="text/css">
<title>批处理实例菜单</title>
</head>

<body>
<p>批处理实例脚本 <span class="Notes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span> <span class="Notes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><a href="./GRUB4DOS11批处理实例菜单_2.htm">批处理实例脚本_2</a> <span class="Notes">&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><a href="./GRUB4DOS11批处理实例菜单_3.htm">批处理实例脚本_3</a></p>
<p><span class="Options">!BAT</span><br>
  <span class="Notes">::批处理菜单文件必须以!BAT开头，可以使用::来注释一行命令的执行<br>
  ::GRUB4DOS 简易批处理脚本 by chenall （WENV版）<br>
  ::用途: 在合盘时省去写大量菜单的麻烦.<br>
  ::用法:<br>
  ::     &nbsp;&nbsp;&nbsp;&nbsp;1.直接启动.<br>
  ::        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;例子:<br>
  ::&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; default 0<br>
  ::            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;timeout 5<br>
  ::            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;title 1.Windows NT/2k/XP/Vista Change Password / Registry Editor<br>
  ::            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;RUN NT-PASS.ISO<br>
  ::            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;boot<br>
  ::             &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;tile 2.MAXDOS Tools Box<br>
  ::             &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;RUN MAXDOS.IMG<br>
  ::             &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;boot<br>
  ::  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;注意: 1. 扩展名为gz/img/ima 默认都当成软盘来启动.ISO作为一个光盘镜像来启动.<br>
  ::        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2. 本脚本默认镜像文件路径是(bd)/BOOT/IMGS/,可以自己修改成其它路径.<br>
  ::     &nbsp;&nbsp;&nbsp;&nbsp;2.自动根据/BOOT/IMGS/目录下的文件生成菜单.(固定用法)<br>
  ::           &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;title auto make menu for /BOOT/IMGS/<br>
  ::                 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;RUN .automenu<br>
  ::                 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;configfile (md)0x3000+0x10<br>
  ::     &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;说明: 自动生成的菜单可以自定义title.默认是启动镜像文件名.<br>
  ::             &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 如果有对应的TXT文件,则会把该文件作为菜单标题。<br>
  ::  本脚本需要GRUB4DOS 2010-12-14 以上的版本.<br>
  ::  更多信息访问 <a href="http://chenall.net/post/grub4dos_run/" target="_blank">http://chenall.net/post/grub4dos_run/</a><br>
  ::  增强版请访问：<br>
  ::<a href="http://bbs.wuyou.com/viewthread.php?tid=183722" target="_blank">http://bbs.wuyou.com/viewthread.php?tid=183722</a> (by zxw@wuyou)<br>
  ::<a href="http://bbs.wuyou.com/viewthread.php?tid=182793" target="_blank">http://bbs.wuyou.com/viewthread.php?tid=182793</a> (by sratlf@wuyou)<br>
  ::==============================================================================</span><br>
  <span class="bat">debug</span> <span class="Options">off</span><br>
  <span class="Notes">::&nbsp;&nbsp;&nbsp;关闭debug模式</span>  <br>
  <span class="bat">checkrange</span> <strong>20101214:-1</strong> <span class="bat">read</span> <strong>0x8278</strong> <span class="Options">||</span> <span class="bat">echo</span> <strong>Err.version </strong><span class="Options">&amp;&amp;</span> <span class="bat">exit 1</span><br>
  <span class="Notes">::&nbsp;&nbsp;&nbsp;检测grldr版本，若是2010年12月14日前编译的就显示 <strong>Err.version</strong>，并退出批处理的执行</span><br>
  <span class="bat">goto</span> <strong>%~x1</strong><br>
  <span class="Notes">::&nbsp;&nbsp;&nbsp;跳至以第一个参数的扩展名为标签名的标签</span><br>
  <span class="bat">exit</span><br>
<span class="Notes">::&nbsp;&nbsp;&nbsp;退出批处理的执行</span></p>
<p> <span class="cmd">:.img<br>
  :.ima<br>
  :.gz</span><br>
  <span class="Notes">::&nbsp;&nbsp;&nbsp;标签名，本段脚本用来启动软驱类镜像文件（可经过gzip压缩）</span><br>
  <span class="bat">map</span> <span class="Options">–mem</span> <strong>(bd)/BOOT/IMGS/%1</strong> <span class="bat">(fd0)</span><br>
  <span class="Notes">::&nbsp;&nbsp;&nbsp;将启动设备/BOOT/IMGS/目录下，通过%1参数指定的软驱镜像载入内存后仿真为第一软驱(fd0)</span><br>
  <span class="bat">map</span> <span class="Options">--hook</span><br>
  <span class="Notes">::&nbsp;&nbsp;&nbsp;使仿真生效</span> <br>
  <span class="bat">rootnoverify</span> <strong>(fd0) </strong><br>
  <span class="Notes">::&nbsp;&nbsp;&nbsp;设置(fd0)为根设备，忽略测试该分区的文件系统是否可以识别</span><br>
  <span class="bat">chainloader</span> <strong>+1 </strong><br>
  <span class="Notes">::&nbsp;&nbsp;&nbsp;链式加载(fd0)的第一个扇区内容</span><br>
<span class="bat">exit</span><br>
<span class="Notes">::&nbsp;&nbsp;&nbsp;退出批处理的执行</span></p>
<p>  <span class="cmd">:.iso</span><br>
  <span class="Notes">::&nbsp;&nbsp;&nbsp;标签名，本段脚本用来启动iso镜像文件</span><br>
<span class="bat">map</span> <span class="Options">–mem</span> <strong>(bd)/BOOT/IMGS/%1</strong> <span class="bat">(0xff)</span><br>
<span class="Notes">::&nbsp;&nbsp;&nbsp;将启动设备/BOOT/IMGS/目录下，通过%1参数指定的ISO镜像载入内存后仿真为(0xff)光驱设备</span><br>
<span class="bat">map</span> <span class="Options">–hook</span><br>
<span class="Notes">::&nbsp;&nbsp;&nbsp;使仿真生效</span><br>
<span class="bat">chainloader</span><strong> (0xff)</strong><br>
<span class="Notes">:: &nbsp;&nbsp;&nbsp;从(0xff)设备启动 </span><br>
<span class="bat">exit</span><br>
<span class="Notes">::&nbsp;&nbsp;&nbsp;退出批处理的执行</span></p>
<p>  <span class="cmd">:.automenu</span><br>
  <span class="Notes">::&nbsp;&nbsp;&nbsp;标签名，本段脚本用来生成自动菜单</span><br>
  <span class="bat">insmod</span> <strong>WENV</strong><br>
  <span class="Notes">::&nbsp;&nbsp;&nbsp; 将外部命令 WENV 加载至内存</span><br>
  <span class="bat">WENV</span> <span class="Options">dir</span><strong> (bd)/BOOT/IMGS/</strong> <span class="Options">&gt;</span> <strong>(md)0x3800+0x80</strong><br>
  <span class="Notes">::&nbsp;&nbsp;&nbsp;  使用WENV的 dir 命令列出启动设备/BOOT/IMGS/文件夹下的所有文件，写入内存7M开始的，长度为64K的区域</span><br>
  <span class="bat">echo</span> <span class="Options">-e</span> <strong>default 0</strong><span class="Options">\n</span><strong>timeout 10</strong><span class="Options">\n</span> <span class="Options">&gt;</span> <strong>(md)0x3000+0x10</strong><br>
  <span class="Notes">::&nbsp;&nbsp;&nbsp; 将该字符串写入到内存6M开始的，长度为8K的区域，使用 \n 进行换行写入，定义生成的菜单文件等待时间和默认项</span><br>
  <span class="bat">WENV</span> <span class="Options">for /f</span> <strong>%i</strong> <span class="Options">in</span> <strong>( (md)0x3800+0x80 ) </strong><span class="Options">do</span> <span class="bat">exec</span> <strong>RUN .makemenu %i</strong><br>
  <span class="Notes">::&nbsp;&nbsp;&nbsp;  使用 WENV 的 for 循环功能，逐项将内存0x3800+0x80段存储的文件名作为参数跳转至 .makemenu 标签执行</span><br>
  <span class="bat">echo</span> <span class="Options">-e</span> <span class="Options">\n</span><strong>title Back to main menu(configfile (md)4+8)</strong><span class="Options">\n</span><strong>configfile (md)4+8</strong> <span class="Options">&gt;&gt;</span><strong> (md)0x3000+0x10</strong><br>
  <span class="Notes">::&nbsp;&nbsp;&nbsp; 待所有文件均处理完后追加写入最后一项菜单，返回主菜单 </span><br>
<span class="bat">goto :eof</span><br>
<span class="Notes">::&nbsp;&nbsp;&nbsp;跳至批处理执行的末尾，等同于结束批处理的执行</span></p>
<p>  <span class="cmd">:.makemenu</span><br>
  <span class="Notes">::&nbsp;&nbsp;&nbsp;标签名，本段脚本用来生成自动菜单的菜单正文部分</span><br>
  <span class="bat">WENV</span> <span class="Options">check</span> <strong>“#.txt#”==“#%~x2#”</strong> <span class="Options">&amp;&amp;</span> <span class="bat">goto :eof</span><br>
  <span class="Notes">::&nbsp;&nbsp;&nbsp;  对文件进行简单的检测，若是txt文本文件就结束本次执行，处理下一个文件</span><br>
  <span class="bat">cat </span><span class="Options">–length</span><strong>=0 (bd)/BOOT/IMGS/%~n2.TXT</strong> <span class="Options">&amp;&amp; </span><span class="bat">cat </span><strong>(bd)/BOOT/IMGS/%~n2.TXT</strong> <span class="Options">&gt;&gt;</span> <strong>(md)0x3000+0x10</strong><span class="Options"> !</span> <span class="bat">echo</span><strong> title %2</strong> <span class="Options">&gt;&gt;</span> <strong>(md)0x3000+0x10</strong><br>
  <span class="Notes">::&nbsp;&nbsp;&nbsp;  检测和参数同名的txt文件是否存在，存在的话将txt文本内容作为该项菜单的标题，否则使用参数名作为该项菜单的标题，追加写入内存中</span><br>
<span class="bat">echo</span> <span class="Options">-e \n</span><strong>RUN %2</strong><span class="Options">\n</span><strong>boot</strong> <span class="Options">&gt;&gt;</span><strong> (md)0x3000+0x10</strong><br>
<span class="Notes">::&nbsp;&nbsp;&nbsp;追加写入本项菜单的执行命令</span></p>
</body>
</html>
